Features
This is a blank ASP.NET MVC 4 project that you can use as a quick start for your own ASP.NET MVC Calendar implementation.
It includes basic configuration (week view)
It initializes the Calendar using the server-side OnInit event
It loads sample calendar event data from a dummy DataManager class
Drag and drop event moving is enabled
License
Licensed for testing and evaluation purposes. You can use the source code of the tutorial if you are a licensed user of DayPilot Pro for ASP.NET MVC.
Requirements
Visual Studio
.NET Framework 4.5+
Included
ASP.NET MVC 4 (4.0.40804.0), as a NuGet reference
DayPilot Pro for ASP.NET MVC (trial) as a local reference
MVC View
Views/Home/Index.cshtml
@using DayPilot.Web.Mvc
@using DayPilot.Web.Mvc.Enums
@using DayPilot.Web.Mvc.Events.Calendar
@using ViewType = DayPilot.Web.Mvc.Enums.Calendar.ViewType
@section TitleContent {
ASP.NET MVC 4 Calendar
}
<h1>Calendar</h1>
<script src="~/Scripts/DayPilot/daypilot-all.min.js"></script>
@Html.DayPilotCalendar("dp", new DayPilotCalendarConfig()
{
BackendUrl = @Url.Action("Calendar", "Backend"),
StartDate = new DateTime(2017, 1, 1),
ViewType = ViewType.Week,
EventMoveHandling = EventMoveHandlingType.Notify
})
For additional configuration options, please see the event calendar documentation.
MVC Backend Controller
Controllers/BackendController.cs
using System.Web.Mvc;
using DayPilot.Web.Mvc;
using DayPilot.Web.Mvc.Enums;
using DayPilot.Web.Mvc.Events.Calendar;
using TutorialMvc4CalendarQuickStart.Data;
namespace TutorialMvc4CalendarQuickStart.Controllers
{
[HandleError]
public class BackendController : Controller
{
public ActionResult Calendar()
{
return new Dpc().CallBack(this);
}
}
class Dpc : DayPilotCalendar
{
protected override void OnInit(InitArgs e)
{
// load events
Events = new DataManager().GetData();
DataIdField = "Id";
DataTextField = "Text";
DataStartField = "Start";
DataEndField = "End";
// request a full update (resources and events)
Update(CallBackUpdateType.Full);
}
protected override void OnEventMove(EventMoveArgs e)
{
new DataManager().MoveEvent(e.Id, e.NewStart, e.NewEnd, e.NewResource);
}
}
}